Interactive Template
Interactive message templates expand the content you can send recipients beyond the standard message template and media messages template types to include interactive buttons using the components object.
There are two types of predefined buttons offered:
-
Call-to-Action — Allows your customer to call a phone number and visit a website
-
Quick Reply — Allows your customer to return a simple text message
These buttons can be attached to text messages or media messages. Once your interactive message templates have been created and approved, you can use them in notification messages as well as customer service/care messages.
Parameters:
Name | Description | JSON Type | Constraints | Required |
---|---|---|---|---|
subtype | The type of interactive button. | String | callToAction, quickReply | Yes |
index | Order of the quick reply options. | Number | For quickReply, values could be 0, 1 and 2. For CTA, values could be 0 and 1 only | Yes |
type | Describes the button type. | String | Text payload | Yes |
payload | Unique Identifier for the button. | String | Used for Quick Reply type only. | Yes |
text | String | Used for CTA options. | No |
Case: Quick Reply with 3 Buttons
Case: Text (Body) with Variables and Quick Reply Buttons
Payload
{
"messages": [
{
"sender": "918010XXXXXX",
"to": "919999XXXXXX",
"messageId": "xxxxx",
"transactionId": "",
"callbackDlrUrl": "http://xxx.com/msgid/status",
"channel": "wa",
"type": "template",
"template": {
"body": [
{
"type": "text",
"text": "Hi"
}
],
"templateId": "test_sinch",
"langCode": "en",
"buttons": [
{
"index": "0",
"subType": "quickReply",
"parameters": {
"type": "payload",
"payload": "Bad"
}
},
{
"index": "1",
"subType": "quickReply",
"parameters": {
"type": "payload",
"payload": "Average"
}
},
{
"index": "2",
"subType": "quickReply",
"parameters": {
"type": "payload",
"payload": "Awesome"
}
}
]
}
}
],
"responseType": "json"
}
Note: 'type' field will have the value as 'template', 'templateID' field refers to template name which should be passed in small characters only, 'button' object will have 'index' field which can have values between 0-2 depending on the number of Quick Reply buttons. Also, the value in 'callbackDlrUrl' will be honoured only if default DLR URL is configured for you business.
Case: Quick Reply with 2 Buttons and Image
Payload
{
"messages": [
{
"sender": "918010XXXXXX",
"to": "919999XXXXXX",
"messageId": "",
"callbackDlrUrl": "https://xxx.com",
"transactionId": "",
"channel": "wa",
"type": "mediaTemplate",
"mediaTemplate": {
"mediaUrl": "https://www.xxx.com/image.png",
"contentType": "image/jpeg",
"template": "test_sinch",
"parameters": {
"1": "test",
"2": "var2",
"3": "test"
},
"langCode": "en",
"buttons": [
{
"index": "0",
"subType": "quickReply",
"parameters": {
"type": "payload",
"payload": "Contact Us"
}
},
{
"index": "1",
"subType": "quickReply",
"parameters": {
"type": "payload",
"payload": "Ticket Status"
}
}
]
}
}
],
"responseType": "json"
}
Note: 'type' field will have the value as 'mediaTemplate', 'templateID' field refers to template name which should be passed in small characters only, 'button' object will have 'index' field which can have values between 0-2 depending on the number of Quick Reply buttons. Also, the value in 'callbackDlrUrl' will be honoured only if default DLR URL is configured for you business.
Case: Image with CTA options
Payload
{
"messages": [
{
"sender": "918010XXXXXX",
"to": "919999XXXXXX",
"messageId": "xxxxx",
"callbackDlrUrl": "http://xxx.com",
"transactionId": "",
"channel": "wa",
"type": "mediaTemplate",
"mediaTemplate": {
"mediaUrl": "https://www.xxx.com/image.png",
"contentType": "image/jpeg",
"template": "test_sinch",
"parameters": {
"1": "test",
"2": "test2"
},
"langCode": "en",
"buttons": [
{
"index": "0",
"subType": "callToAction",
"parameters": {
"type": "text",
"text": "Call"
}
},
{
"index": "1",
"subType": "callToAction",
"parameters": {
"type": "text",
"text": "Chat"
}
}
]
}
}
],
"responseType": "json"
}
Note: 'type' field will have the value as 'mediaTemplate', 'templateID' field refers to template name which should be passed in small characters only, 'button' object will have 'index' field which can have values between 0-2 depending on the number of Quick Reply buttons. Also, the value in 'callbackDlrUrl' will be honoured only if default DLR URL is configured for you business.
Multiple Button Template Message-
Enterprises are now able to send the templated message, which can have a mixture of up to 10 button components total. Currently our platform Support- Phone Number Button, URL Button, Quick Reply Button, Copy Code Button. The user has to define an index of each button which indicates the order in which button should be visible to the user.
Parameters:
Placeholder | Description | Example Value |
---|---|---|
Type- Phone Number Button | ||
TEXT | Phone Number to be called. | 910000000000 |
Type- Button, Subtype- URL | ||
TYPE | Fixed Value- text. | Text |
text | Developer-provided suffix that is appended to the predefined prefix URL in the template. | ABCD |
Type- Button, Subtype- quick_reply | ||
TYPE | Fixed Value- payload. | payload |
Payload | Developer-defined payload that is returned when the button is clicked in addition to the display text on the button. | ABCD |
Type- Button, Subtype- copy_code | ||
TYPE | Fixed Value- coupon_code. | coupon_code |
coupon_code | Coupon Code that can be copies by the user. | ABCD |
Payload
{
"recipient_type": "individual",
"to": "91XXXXXXXXXX",
"type": "template",
"template": {
"name": "test_1",
"language": {
"code": "en_US",
"policy": "deterministic"
},
"components": [
{
"type": "header",
"parameters": [
{
"text": "hi there",
"type": "text"
}
]
},
{
"type": "body",
"parameters": [
{
"text": "hi there",
"type": "text"
},
{
"text": "hi",
"type": "text"
},
{
"text": "hi",
"type": "text"
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
"payload": "payload -1"
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "1",
"parameters": [
{
"type": "payload",
"payload": "payload-2"
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "2",
"parameters": [
{
"type": "payload",
"payload": "payload-3"
}
]
},
{
"type": "button",
"sub_type": "url",
"index": "3",
"parameters": [
{
"type": "text",
"text": "https://www.youtube.com"
}
]
},
{
"type": "button",
"sub_type": "url",
"index": "4",
"parameters": [
{
"type": "text",
"text": "https://www.youtube.com"
}
]
},
{
"type": "phone_number",
"index": "5",
"text": "910000000000"
},
{
"type": "button",
"sub_type": "copy_code",
"index": "6",
"parameters": [
{
"type": "coupon_code",
"coupon_code": "1234"
}
]
}
]
}
}
Limitations-
- Phone Number Button- Only one phone number button is allowed.
- URL Button- Only two URL buttons are allowed.
- Copy Code button- Only one copy code button is allowed.
- Quick Reply Button- Upto 10 quick reply buttons. If using quick reply buttons with other buttons, buttons must be organized into two groups: quick reply buttons and non-quick reply buttons. Quick Reply Buttons should be grouped one after another only without any Non-QR group button in between.
Note: Calback URL is a optional paramter . Please use when you want to change the default URL(configured through smartta). It will only chnage the domain name othere paratemters will be same as configurated in smartta.